//! MetaPages.debug.js
//

(function() {

Type.registerNamespace('MetaPages.Classes');

////////////////////////////////////////////////////////////////////////////////
// CssInfo

CssInfo = function CssInfo() {
    /// <field name="_abouters$3" type="String" static="true">
    /// </field>
    /// <field name="_instance$3" type="CssInfo" static="true">
    /// </field>
    /// <field name="_cssProps$3" type="Array" elementType="String" static="true">
    /// </field>
    /// <field name="_btn" type="jQueryObject">
    /// </field>
    /// <field name="_about$3" type="jQueryObject">
    /// </field>
    /// <field name="_metaItem$3" type="String" static="true">
    /// </field>
    CssInfo.initializeBase(this);
    this.element = $("<div class='CssInfo MetaControl'/>").appendTo(document.body).hide().bind('keydown.esc', ss.Delegate.create(this, function(e) {
        Keys.escKey(e, ss.Delegate.create(this, function() {
            this.destroy();
        }));
    }));
    $('body *:not(.MetaControl)').live('mouseover.CssInfo', ss.Delegate.create(this, this._mouseEnter$3));
    $(document.body).bind('mousemove.CssInfo', ss.Delegate.create(this, function(e) {
        if (this.element != null) {
            this.element.css({ top: e.pageY + 34, left: e.pageX - 80 });
        }
    }));
}
CssInfo.ev = function CssInfo$ev(e, btn) {
    /// <param name="e" type="jQueryEvent">
    /// </param>
    /// <param name="btn" type="jQueryObject">
    /// </param>
    if (CssInfo._instance$3 == null) {
        CssInfo._instance$3 = new CssInfo();
        CssInfo._instance$3._btn = btn;
        btn.addClass('Toggled');
    }
    else {
        CssInfo._instance$3.destroy();
    }
}
CssInfo.prototype = {
    _btn: null,
    _about$3: null,
    
    destroy: function CssInfo$destroy() {
        CssInfo._instance$3 = null;
        $('body *:not(.MetaControl)').die('mouseover.CssInfo');
        $(document.body).unbind('mousemove.CssInfo');
        new Await().addDx(ss.Delegate.create(this, function() {
            if (this._about$3 != null) {
                this._about$3.removeClass('Selector');
            }
            if (this.element != null) {
                this.element.remove();
            }
            if (this._btn != null) {
                this._btn.removeClass('Toggled').removeAttr('disabled');
            }
        })).commit();
    },
    
    _mouseEnter$3: function CssInfo$_mouseEnter$3(e) {
        /// <param name="e" type="jQueryEvent">
        /// </param>
        if (this._about$3 != null) {
            this._about$3.removeClass('Selector');
        }
        else {
            this.element.show();
        }
        this._about$3 = $(e.target);
        this.element.empty();
        this._about$3.addClass('Selector');
        var p = this._about$3.offset();
        var ls = this.element;
        var id = (this._about$3.attr('id') != null) ? '#' + this._about$3.attr('id') : '';
        var cn = this._about$3[0].tagName.toUpperCase() + id;
        $("<div class='Item MetaControl'/>").appendTo(ls).html(cn).css('font-weight', 'bold');
        $("<div class='Item MetaControl'/>").appendTo(ls).html('Classes: ' + this._about$3.attr('class').replaceAll('Selector', ''));
        var $enum1 = ss.IEnumerator.getEnumerator(CssInfo._cssProps$3);
        while ($enum1.moveNext()) {
            var n = $enum1.current;
            $("<div class='Item MetaControl'/>").appendTo(ls).html(n + ': ' + this._about$3.css(n));
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// Test

Test = function Test(name) {
    /// <param name="name" type="String">
    /// </param>
    /// <field name="defaultTestSpeed" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="waitSleep" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="hasContent" type="String" static="true">
    /// </field>
    /// <field name="isEmpty" type="String" static="true">
    /// </field>
    /// <field name="isNumber" type="String" static="true">
    /// </field>
    /// <field name="askOkBtn" type="String" static="true">
    /// </field>
    /// <field name="askCancelBtn" type="String" static="true">
    /// </field>
    /// <field name="maxWait" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="testSpeed" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="_indent$1" type="String" static="true">
    /// </field>
    /// <field name="_savedSpeeds$1" type="Array" static="true">
    /// </field>
    /// <field name="testUserId" type="String" static="true">
    /// </field>
    /// <field name="testVars" type="Object" static="true">
    /// </field>
    /// <field name="_rxNumber$1" type="RegExp" static="true">
    /// </field>
    /// <field name="_instances$1" type="Object" static="true">
    /// </field>
    /// <field name="name" type="String">
    /// </field>
    /// <field name="lastSelect" type="jQueryObject">
    /// </field>
    /// <field name="_suite" type="TestSuite">
    /// </field>
    /// <field name="_endStep$1" type="Number" integer="true">
    /// </field>
    /// <field name="_endTime$1" type="Number" integer="true">
    /// </field>
    /// <field name="_overtime$1" type="Number" integer="true">
    /// </field>
    /// <field name="_skipCnt$1" type="Number" integer="true">
    /// </field>
    /// <field name="_startStep$1" type="Number" integer="true">
    /// </field>
    /// <field name="_startTime$1" type="Number" integer="true">
    /// </field>
    /// <field name="_recurStop$1" type="Number" integer="true" static="true">
    /// </field>
    Test.initializeBase(this);
    this.name = name;
    TestInstance.theTest = this;
}
Test.addInstance = function Test$addInstance(cls) {
    /// <param name="cls" type="Object">
    /// </param>
    Test._instances$1[Type.getInstanceType(cls).get_fullName()] = cls;
}
Test.getInstance = function Test$getInstance(type) {
    /// <param name="type" type="Type">
    /// </param>
    /// <returns type="Object"></returns>
    return Test._instances$1[type.get_fullName()];
}
Test.getVar = function Test$getVar(key) {
    /// <param name="key" type="String">
    /// </param>
    /// <returns type="Object"></returns>
    var v = Test.testVars[key];
    if (Test._recurStop$1 > 100) {
        return v;
    }
    Test._recurStop$1++;
    if (typeof(v) === 'function') {
        var fn = v;
        v = fn();
    }
    if (Type.canCast(v, String) && (v).charAt(0) === '@' && (v).charAt(1) !== '{') {
        v = Test.getVar(v);
    }
    if (Type.canCast(v, String)) {
        v = Test.formatVars(v);
    }
    Test._recurStop$1--;
    return v;
}
Test.setVar = function Test$setVar(key, v) {
    /// <param name="key" type="String">
    /// </param>
    /// <param name="v" type="Object">
    /// </param>
    Test.testVars[key] = v;
}
Test.formatVars = function Test$formatVars(txt) {
    /// <param name="txt" type="String">
    /// </param>
    /// <returns type="String"></returns>
    var replaceVarsRx = /@\{([-a-z0-9_.]+?)\}/gi;
    var idx = replaceVarsRx.lastIndex = 0;
    var ot = '';
    var mm = replaceVarsRx.exec(txt);
    while (mm != null) {
        var st = replaceVarsRx.lastIndex - mm[0].length;
        if (st > idx) {
            ot += txt.substring(idx, st);
        }
        if (mm[1] != null) {
            ot += Test.getVar('@' + mm[1]) || '[' + mm[1] + ']';
        }
        idx = replaceVarsRx.lastIndex;
        mm = replaceVarsRx.exec(txt);
    }
    if (idx < txt.length) {
        ot += txt.substr(idx);
    }
    return ot;
}
Test.eq = function Test$eq(name, tt) {
    /// <param name="name" type="Object">
    /// </param>
    /// <param name="tt" type="Test">
    /// </param>
    /// <returns type="Object"></returns>
    if (name != null) {
        if (typeof(name) === 'function') {
            name = name(tt);
        }
        var nm = name.toString();
        if (nm.charAt(0) === '@' && nm.charAt(1) !== '{') {
            name = Test.getVar(nm);
        }
        if (Type.canCast(name, String)) {
            name = Test.formatVars(name);
        }
    }
    return name;
}
Test.prototype = {
    name: null,
    lastSelect: null,
    _suite: null,
    _endStep$1: 0,
    _endTime$1: 0,
    _overtime$1: 0,
    _skipCnt$1: 0,
    _startStep$1: 0,
    _startTime$1: 0,
    
    get_testTime: function Test$get_testTime() {
        /// <value type="String"></value>
        return ((this._endTime$1 - this._startTime$1) / 1000).toPrecision(4);
    },
    
    addToSuite: function Test$addToSuite(suite) {
        /// <param name="suite" type="TestSuite">
        /// </param>
        /// <returns type="Test"></returns>
        suite.tests[this.name.toLowerCase()] = this;
        return this;
    },
    
    reset: function Test$reset() {
        /// <returns type="Test"></returns>
        this._startTime$1 = this._endTime$1 = new Date().getTime();
        this.lastSelect = null;
        this._overtime$1 = 0;
        Test.testSpeed = 1;
        Test._savedSpeeds$1 = [];
        TestSuite.tell(null);
        return this;
    },
    
    runTest: function Test$runTest(awp) {
        /// <param name="awp" type="Await">
        /// </param>
        /// <returns type="Test"></returns>
        if (ss.isNullOrUndefined(awp)) {
            this.addDx(ss.Delegate.create(this, function() {
                this._endTime$1 = new Date().getTime();
                var msg = String.format('<b>Test Passed</b> - run time = {0}s', this.get_testTime());
                Inform.log(msg);
                TestSuite.tell(msg).addClass('Passed').removeClass('Failed');
            }));
        }
        else {
            this.addDx(function(aw) {
                var taw = aw;
                var tawp = awp;
                tawp.lastSelect = taw.lastSelect;
            });
        }
        this.commit(awp);
        return this;
    },
    
    _testFailed$1: function Test$_testFailed$1() {
        this._endTime$1 = new Date().getTime();
        var msg = String.format('<b>Test Failed</b> - run time = {0}s', this.get_testTime());
        Inform.error(msg);
        TestSuite.tell(msg).addClass('Failed').removeClass('Passed');
    },
    
    _isValid$1: function Test$_isValid$1(a, b) {
        /// <param name="a" type="Object">
        /// </param>
        /// <param name="b" type="Object">
        /// </param>
        /// <returns type="Boolean"></returns>
        var aS = (ss.isValue(a)) ? a.toString() : null;
        var bS = (ss.isValue(b)) ? b.toString() : null;
        if (bS != null) {
            switch (bS) {
                case '[HasContent]':
                    return !String.isNullOrEmpty(aS);
                case '[IsEmpty]':
                    return String.isNullOrEmpty(aS);
                case '[IsNumber]':
                    return Test._rxNumber$1.test(aS);
            }
        }
        var ic = aS === bS;
        return ic;
    },
    
    call: function Test$call(t, dict) {
        /// <param name="t" type="Test">
        /// </param>
        /// <param name="dict" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        this.addDl(ss.Delegate.create(this, function(aw) {
            if (this._skipCnt$1 > 0) {
                aw.done();
                return;
            }
            if (typeof(t) === 'string') {
                var nm = t;
                t = this._suite.tests[nm.toLowerCase()];
                if (t == null) {
                    throw new Error(Exceptions.invalidTestCaseName);
                }
            }
            t.reset();
            if (dict != null) {
                var $dict1 = dict;
                for (var $key2 in $dict1) {
                    var p = { key: $key2, value: $dict1[$key2] };
                    Test.setVar(p.key, p.value);
                }
            }
            t.runTest(aw);
        }));
        return this;
    },
    
    delay: function Test$delay(ms) {
        /// <param name="ms" type="Number" integer="true">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('Delay', ms, ss.Delegate.create(this, function() {
            window.setTimeout(ss.Delegate.create(this, function() {
                this.done();
            }), ms);
        }));
    },
    
    pushMaxWait: function Test$pushMaxWait(ms) {
        /// <param name="ms" type="Number" integer="true">
        /// </param>
        /// <returns type="Test"></returns>
        this.addDx(function() {
            Test.maxWait = ms;
        });
        return this;
    },
    
    popMaxWait: function Test$popMaxWait() {
        /// <returns type="Test"></returns>
        this.addDx(function() {
            Test.maxWait = 10000;
        });
        return this;
    },
    
    speed: function Test$speed(ms) {
        /// <param name="ms" type="Number" integer="true">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('Speed', ms, ss.Delegate.create(this, function() {
            if (arguments.length > 0) {
                Test._savedSpeeds$1.add(Test.testSpeed);
                Test.testSpeed = ms;
            }
            else {
                Test.testSpeed = Test._savedSpeeds$1[Test._savedSpeeds$1.length - 1];
                Test._savedSpeeds$1.removeAt(Test._savedSpeeds$1.length - 1);
            }
            this.nextTest();
        }));
    },
    
    step: function Test$step(name, arg1, arg2, fn, skipFn) {
        /// <param name="name" type="String">
        /// </param>
        /// <param name="arg1" type="String">
        /// </param>
        /// <param name="arg2" type="Object">
        /// </param>
        /// <param name="fn" type="System.Action`1">
        /// </param>
        /// <param name="skipFn" type="Function">
        /// </param>
        /// <returns type="Test"></returns>
        var aName = (arguments.length > 1) ? name : '';
        var aArg1 = (arguments.length > 2) ? arg1 : '';
        var aArg2 = (arguments.length > 3) ? arg2 : null;
        switch (arguments.length) {
            case 1:
                fn = arguments[0];
                break;
            case 2:
                fn = arguments[1];
                break;
            case 3:
                fn = arguments[2];
                break;
        }
        this.addDl(ss.Delegate.create(this, function(aw) {
            var log = (aArg2 != null) ? String.format('.{0}("{1}", "{2}")', aName, Test.eq(aArg1), Test.eq(aArg2, this)) : String.format('.{0}("{1}")', aName, Test.eq(aArg1, this));
            if (this._skipCnt$1 > 0) {
                if (skipFn != null) {
                    skipFn();
                }
                aw.done();
                return;
            }
            Inform.log(log);
            TestSuite.tell(log).removeClass('Passed').removeClass('Failed');
            this._overtime$1 = new Date().getTime() + Test.maxWait;
            this._startStep$1 = new Date().getTime();
            fn(aw);
            this._endStep$1 = new Date().getTime();
        }));
        return this;
    },
    
    nextTest: function Test$nextTest() {
        /// <returns type="Test"></returns>
        window.setTimeout(ss.Delegate.create(this, function() {
            this.done();
        }), Test.testSpeed);
        return this;
    },
    
    goTo: function Test$goTo(page) {
        /// <param name="page" type="String">
        /// </param>
        /// <returns type="Test"></returns>
        page = Strings.safeFileName(page);
        return this.waitIO().step('GoTo', page, ss.Delegate.create(this, function() {
            Master.GoPage(ThemeYoshi.defaultPageClass, Test.eq(page).toString());
            this.nextTest();
        })).waitIO();
    },
    
    runPageSuite: function Test$runPageSuite(suite) {
        /// <param name="suite" type="String">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('RunSuite', suite, ss.Delegate.create(this, function() {
            TestSuite.getTestSuiteByPage(suite).runAllAw(this);
        }));
    },
    
    requireTestUser: function Test$requireTestUser() {
        /// <returns type="Test"></returns>
        return this.step('RequireTestUser', ss.Delegate.create(this, function() {
            var id = Nsb.Storage.getLocal(Test.testUserId);
            if (!ss.isValue(id)) {
                this._testFailed$1();
            }
            else {
                this.nextTest();
            }
        }));
    },
    
    waitIO: function Test$waitIO() {
        /// <returns type="Test"></returns>
        return this.sleep(10).addDl(ss.Delegate.create(this, function() {
            this._waitIOAction$1();
        })).sleep(10);
    },
    
    _waitIOAction$1: function Test$_waitIOAction$1() {
        if (FileBlobBase.svCnt > 0) {
            window.setTimeout(ss.Delegate.create(this, this._waitIOAction$1), 13);
        }
        else {
            this.done();
        }
    },
    
    waitFor: function Test$waitFor(select, value) {
        /// <summary>
        /// Waits for an element or condition and tests against value if given.
        /// Found element must test visible.
        /// </summary>
        /// <param name="select" type="Object">
        /// string selector or jquery object or function returning a jquery object or selector
        /// </param>
        /// <param name="value" type="Object">
        /// value to test element content against
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('WaitFor', select.toString(), value, ss.Delegate.create(this, function() {
            this._waitForAction$1(select, value);
        }));
    },
    
    _waitForAction$1: function Test$_waitForAction$1(select, value) {
        /// <param name="select" type="Object">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        select = Test.eq(select, this);
        value = Test.eq(value, this);
        var el;
        var ic;
        if (ss.isValue(value)) {
            el = null;
            var eel = $(select);
            eel.each(ss.Delegate.create(this, function(i, ee) {
                var ths = $(ee);
                if (this._isValid$1(ths.getContent(), value)) {
                    el = ths;
                    return false;
                }
                return true;
            }));
            ic = el != null && el.is(':visible');
        }
        else {
            el = $(select);
            ic = el.length > 0 && el.is(':visible');
        }
        if (ic) {
            this.lastSelect = el;
            this.nextTest();
        }
        else {
            if (new Date().getTime() >= this._overtime$1) {
                this._testFailed$1();
                return;
            }
            window.setTimeout(ss.Delegate.create(this, function() {
                this._waitForAction$1(select, value);
            }), 13);
        }
    },
    
    waitNot: function Test$waitNot(select, value) {
        /// <param name="select" type="Object">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('WaitNot', select.toString(), value, ss.Delegate.create(this, function() {
            this._waitNotAction$1(select, value);
        }));
    },
    
    _waitNotAction$1: function Test$_waitNotAction$1(select, value) {
        /// <param name="select" type="Object">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        select = Test.eq(select, this);
        value = Test.eq(value, this);
        var el;
        var ic;
        if (ss.isValue(value)) {
            el = null;
            var eel = $(select);
            eel.each(ss.Delegate.create(this, function(i, ee) {
                var ths = $(ee);
                if (this._isValid$1(ths.getContent(), value)) {
                    el = ths;
                    return false;
                }
                return true;
            }));
            ic = el == null || !el.is(':visible');
        }
        else {
            el = $(select);
            ic = !el.length || !el.is(':visible');
        }
        if (ic) {
            this.nextTest();
        }
        else {
            if (new Date().getTime() >= this._overtime$1) {
                this._testFailed$1();
                return;
            }
            window.setTimeout(ss.Delegate.create(this, function() {
                this._waitNotAction$1(select, value);
            }), 13);
        }
    },
    
    doIf: function Test$doIf(select, value, timeout) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <param name="timeout" type="Number" integer="true">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('DoIf', select, value, ss.Delegate.create(this, function() {
            this._ifAction$1(select, value, timeout);
        }), ss.Delegate.create(this, function() {
            this._skipCnt$1++;
        }));
    },
    
    _ifAction$1: function Test$_ifAction$1(select, value, timeout) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <param name="timeout" type="Number" integer="true">
        /// </param>
        value = Test.eq(value, this);
        timeout = (timeout || 0);
        timeout = (timeout < 1000000) ? new Date().getTime() + timeout : timeout;
        var el;
        var ic;
        if (ss.isValue(value)) {
            el = null;
            var eel = $(select);
            eel.each(ss.Delegate.create(this, function(i, ee) {
                var ths = $(ee);
                if (this._isValid$1(ths.getFValue(), value)) {
                    el = ths;
                    return false;
                }
                return true;
            }));
            ic = el != null;
        }
        else {
            el = $(select);
            ic = el.length > 0;
        }
        if (ic) {
            this.lastSelect = el;
        }
        else {
            if (new Date().getTime() < timeout) {
                window.setTimeout(ss.Delegate.create(this, function() {
                    this._ifAction$1(select, value, timeout);
                }), 13);
                return;
            }
            this._skipCnt$1++;
        }
        this.nextTest();
    },
    
    endIf: function Test$endIf() {
        /// <returns type="Test"></returns>
        return this.addDx(ss.Delegate.create(this, function() {
            this._skipCnt$1--;
            if (this._skipCnt$1 <= 0) {
                Inform.log('.EndIf()');
                this._skipCnt$1 = 0;
            }
        }));
    },
    
    set: function Test$set(key, value) {
        /// <param name="key" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        var type = typeof(value);
        return this.step('Set', '[' + key + ']', value, ss.Delegate.create(this, function() {
            var v = value;
            if (type === 'function') {
                var fn = value;
                v = fn(this);
            }
            Test.setVar(key, v);
            this.done();
        }));
    },
    
    setUser: function Test$setUser(id) {
        /// <param name="id" type="String">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('SetUser', id, ss.Delegate.create(this, function() {
            Nsb.Storage.setLocal(Test.testUserId, Test.eq(id));
            Master.GoPage(ThemeYoshi.currentPageName);
            this.nextTest();
        }));
    },
    
    comment: function Test$comment(msg) {
        /// <param name="msg" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        this.addDl(ss.Delegate.create(this, function() {
            var m = Test.eq(msg).toString();
            Inform.log('::: ' + m);
            this.nextTest();
        }));
        return this;
    },
    
    actionDl: function Test$actionDl(fn) {
        /// <param name="fn" type="Awaiter.Function">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('ActionDl', fn.toString().substr(12, 80), ss.Delegate.create(this, function() {
            fn(this);
        }));
    },
    
    actionDx: function Test$actionDx(fn) {
        /// <param name="fn" type="Awaiter.Function">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('ActionDx', fn.toString().substr(12, 80), ss.Delegate.create(this, function() {
            fn(this);
            this.nextTest();
        }));
    },
    
    enter: function Test$enter(arg1) {
        /// <param name="arg1" type="String">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('Enter', arg1, ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.val(Test.eq(arg1, this)).change().blur();
            this.nextTest();
        }));
    },
    
    blur: function Test$blur(select, value) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        if (arguments.length === 1) {
            this.waitFor(select);
        }
        else if (arguments.length === 2) {
            this.waitFor(select, value);
        }
        return this.step('Blur', ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.blur();
            this.nextTest();
        })).waitIO();
    },
    
    focus: function Test$focus(select, value) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        if (arguments.length === 1) {
            this.waitFor(select);
        }
        else if (arguments.length === 2) {
            this.waitFor(select, value);
        }
        return this.step('Focus', ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.focus();
            this.nextTest();
        })).waitIO();
    },
    
    press: function Test$press(select, value) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        if (arguments.length === 1) {
            this.waitFor(select);
        }
        else if (arguments.length === 2) {
            this.waitFor(select, value);
        }
        return this.step('Press', select, value, ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.focus().trigger('mousedown').click().trigger('mouseup');
            this.nextTest();
        })).waitIO();
    },
    
    mouseDown: function Test$mouseDown(select, value) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        if (arguments.length === 1) {
            this.waitFor(select);
        }
        else if (arguments.length === 2) {
            this.waitFor(select, value);
        }
        return this.step('MouseDown', ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.focus().trigger('mousedown');
            this.nextTest();
        })).waitIO();
    },
    
    mouseOver: function Test$mouseOver(select, value) {
        /// <param name="select" type="String">
        /// </param>
        /// <param name="value" type="Object">
        /// </param>
        /// <returns type="Test"></returns>
        if (arguments.length === 1) {
            this.waitFor(select);
        }
        else if (arguments.length === 2) {
            this.waitFor(select, value);
        }
        return this.step('MouseOver', ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.focus().trigger('mouseover').trigger('mouseenter');
            this.nextTest();
        })).waitIO();
    },
    
    keyCode: function Test$keyCode(code) {
        /// <param name="code" type="Number" integer="true">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('KeyCode', code, ss.Delegate.create(this, function() {
            if (this.lastSelect == null) {
                this.abort();
            }
            this.lastSelect.focus();
            var codeStr = (typeof(code) === 'number') ? String.fromCharCode(code) : Test.eq(code).toString();
            for (var i = 0; i < codeStr.length; i++) {
                code = codeStr.charCodeAt(i);
                var ev1 = jQuery.Event("keydown");
                ev1.which = code;
                this.lastSelect.trigger(ev1);
                var ev2 = jQuery.Event("keypress");
                ev2.which = code;
                this.lastSelect.trigger(ev2);
                var ev3 = jQuery.Event("keyup");
                ev3.which = code;
                this.lastSelect.trigger(ev3);
            }
            this.nextTest();
        }));
    },
    
    deleteRecord: function Test$deleteRecord(partitionKey, rowKey) {
        /// <param name="partitionKey" type="String">
        /// </param>
        /// <param name="rowKey" type="String">
        /// </param>
        /// <returns type="Test"></returns>
        return this.step('DeleteRecord', partitionKey + '/' + rowKey, ss.Delegate.create(this, function() {
            FileBlobBase.deleteItemAw(this, partitionKey, rowKey);
        }));
    }
}


////////////////////////////////////////////////////////////////////////////////
// TestSuite

TestSuite = function TestSuite(name) {
    /// <param name="name" type="String">
    /// </param>
    /// <field name="allTestsName" type="String" static="true">
    /// </field>
    /// <field name="suites" type="Object" static="true">
    /// </field>
    /// <field name="teller" type="jQueryObject" static="true">
    /// </field>
    /// <field name="name" type="String">
    /// </field>
    /// <field name="tests" type="Object">
    /// </field>
    this.tests = {};
    this.name = name;
    TestSuite.suites[name.toLowerCase()] = this;
}
TestSuite.runMasterSuite = function TestSuite$runMasterSuite() {
    var suite = TestSuite.getTestSuiteByPage(ThemeYoshi.defaultPageName);
    suite.run('! Run page suite');
}
TestSuite.getVar = function TestSuite$getVar(n) {
    /// <param name="n" type="String">
    /// </param>
    /// <returns type="Object"></returns>
    return Test.getVar(n);
}
TestSuite.setVar = function TestSuite$setVar(n, v) {
    /// <param name="n" type="String">
    /// </param>
    /// <param name="v" type="Object">
    /// </param>
    Test.setVar(n, v);
}
TestSuite.value = function TestSuite$value(o1, o2, o3, o4) {
    /// <param name="o1" type="Object">
    /// </param>
    /// <param name="o2" type="Object">
    /// </param>
    /// <param name="o3" type="Object">
    /// </param>
    /// <param name="o4" type="Object">
    /// </param>
    /// <returns type="Function"></returns>
    return function() {
        return Test.eq(o1) || Test.eq(o2) || Test.eq(o3) || Test.eq(o4);
    };
}
TestSuite.getTestSuiteByPage = function TestSuite$getTestSuiteByPage(pageName) {
    /// <param name="pageName" type="String">
    /// </param>
    /// <returns type="TestSuite"></returns>
    var className = ThemeYoshi.pages.pages[pageName].Tests;
    var keyName = pageName.toLowerCase();
    try {
        if (Type.isClass(Type.getType(className))) {
            if (Object.keyExists(TestSuite.suites, keyName)) {
                return TestSuite.suites[keyName];
            }
            return eval('new ' + className + '()');
        }
    }
    catch ($e1) {
    }
    return null;
}
TestSuite.tell = function TestSuite$tell(msg) {
    /// <param name="msg" type="String">
    /// </param>
    /// <returns type="jQueryObject"></returns>
    if (TestSuite.teller != null) {
        if (!String.isNullOrEmpty(msg)) {
            TestSuite.teller.html(msg).show();
        }
        else {
            TestSuite.teller.html('').hide();
        }
    }
    return TestSuite.teller;
}
TestSuite.prototype = {
    name: null,
    
    run: function TestSuite$run(test) {
        /// <param name="test" type="String">
        /// </param>
        this.runAw(null, test);
    },
    
    runAw: function TestSuite$runAw(awp, test) {
        /// <param name="awp" type="Await">
        /// </param>
        /// <param name="test" type="String">
        /// </param>
        var tt = this.tests[test.toLowerCase()];
        if (tt != null) {
            tt._suite = this;
            tt.reset().runTest(awp);
        }
        else {
            Inform.error('Could not find test {0}', test);
            if (awp != null) {
                awp.done();
            }
        }
    },
    
    testList: function TestSuite$testList() {
        /// <returns type="Object"></returns>
        return DropMenu.listify(this.tests, function(a, b) {
            return String.compare((a).name, (b).name, true);
        }, function(dd, o) {
            dd[(o).name] = (o).name;
        });
    },
    
    runAllAw: function TestSuite$runAllAw(awp) {
        /// <param name="awp" type="Await">
        /// </param>
        this.runAw(awp, '! Run page suite');
    }
}


Type.registerNamespace('MetaTests.Classes');

////////////////////////////////////////////////////////////////////////////////
// TestListMenu

TestListMenu = function TestListMenu(el, nameList, handler) {
    /// <param name="el" type="jQueryObject">
    /// </param>
    /// <param name="nameList" type="Object">
    /// </param>
    /// <param name="handler" type="Nsb.Classes.Function">
    /// </param>
    TestListMenu.initializeBase(this, [ el, nameList, handler ]);
}


Type.registerNamespace('MetaPages.Clusters');

////////////////////////////////////////////////////////////////////////////////
// MetaCluster

MetaCluster = function MetaCluster() {
    /// <field name="_slideSpeed$3" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="testUserId" type="String" static="true">
    /// </field>
    /// <field name="_instance$3" type="MetaCluster" static="true">
    /// </field>
    /// <field name="_usersSimulated$3" type="Boolean" static="true">
    /// </field>
    /// <field name="testTeller" type="jQueryObject" static="true">
    /// </field>
    /// <field name="userSelect" type="jQueryObject" static="true">
    /// </field>
    /// <field name="_regestered$3" type="Boolean" static="true">
    /// </field>
    /// <field name="testUsers" type="Object" static="true">
    /// </field>
    /// <field name="_barMargin$3" type="String">
    /// </field>
    /// <field name="_bodyMargin$3" type="String">
    /// </field>
    /// <field name="_testBtn$3" type="jQueryObject">
    /// </field>
    /// <field name="_testSuite$3" type="TestSuite">
    /// </field>
    /// <field name="_userBoxUpdate$3" type="Boolean">
    /// </field>
    MetaCluster.initializeBase(this);
    new Await().loadCss(Uri.scripts('Css/MetaCluster.css')).waitDx(function() {
        return ThemeYoshi.pages != null;
    }).addDx(ss.Delegate.create(this, function() {
        this.element = $("<div class='MetaCluster'/>").appendTo(document.body).hide();
        this._bodyMargin$3 = $(document.body).css('margin-top');
        this._barMargin$3 = (this.element.height() + parseInt(this._bodyMargin$3)) + 'px';
        $('<button/>').appendTo(this.element).html('css').click(function(e) {
            CssInfo.ev(e, $(e.target));
        });
        $("<button class='RefreshBtn'/>").appendTo(this.element).html('refresh').click(function() {
            if (!String.isNullOrEmpty(window.location.search)) {
                window.location.href = window.location.href.split('?')[0];
            }
            else {
                window.location.reload(true);
            }
        });
        MetaCluster.userSelect = $("<select class='UserSelect'/>").appendTo(this.element);
        $('<option/>').appendTo(MetaCluster.userSelect).attr('value', 'live').html('live user');
        var $dict1 = MetaCluster.testUsers;
        for (var $key2 in $dict1) {
            var p = { key: $key2, value: $dict1[$key2] };
            if (Type.canCast(p.value, String)) {
                $('<option/>').appendTo(MetaCluster.userSelect).attr('value', p.value).html(p.key);
            }
        }
        var awx = new Await().waitDx(function() {
            return Master.fbUser != null && ss.isValue(Master.fbUser.id);
        }, 2000);
        if (ss.isValue(Nsb.Storage.getLocal('TestUserId'))) {
            awx.addDx(function() {
                MetaCluster.userSelect.val(Master.profile.get_myId());
            });
        }
        else {
            awx.addDx(function() {
                MetaCluster.userSelect.val('live');
            });
        }
        awx.addDx(ss.Delegate.create(this, function() {
            MetaCluster.userSelect.change(ss.Delegate.create(this, function() {
                this.changeUser(MetaCluster.userSelect.val());
            }));
        })).addDx(function() {
            new DropMenu(MetaCluster.userSelect, { 'Master.alivenessCheck()': 'Aliveness Check' }, function(e, item) {
                eval(item);
            });
        }).commit();
        MetaCluster.testTeller = $("<div class='TestTeller'/>").appendTo(this.element);
        this._testBtn$3 = $("<button class='RunTestsBtn'/>").appendTo(this.element).html('Run Tests').click(function() {
            TestSuite.runMasterSuite();
        });
        var goPage = $("<select class='GoPage'/>").appendTo(this.element).change(function() {
            Master.GoPage(ThemeYoshi.defaultPageClass, $('.MetaCluster .GoPage').val());
        });
        var $dict3 = ThemeYoshi.pages.pages;
        for (var $key4 in $dict3) {
            var p = { key: $key4, value: $dict3[$key4] };
            $('<option/>').attr('value', p.key).html(p.value.Name).appendTo(goPage);
        }
        this.refresh();
        this.slideDownEv();
    })).commit();
}
MetaCluster.StaticRefresh = function MetaCluster$StaticRefresh() {
    if (MetaCluster._instance$3 != null) {
        MetaCluster._instance$3.refresh();
    }
    else {
        if (Nsb.Storage.getLocal(ThemeYoshi.get_metaBarKey())) {
            MetaCluster.toggleEv();
        }
    }
}
MetaCluster.toggleEv = function MetaCluster$toggleEv(e) {
    /// <param name="e" type="jQueryEvent">
    /// </param>
    Inform.debug('MetaCluster.ToggleEv');
    if (MetaCluster._instance$3 == null) {
        Nsb.Storage.setLocal(ThemeYoshi.get_metaBarKey(), true);
        MetaCluster._instance$3 = new MetaCluster();
    }
    else {
        if (MetaCluster._instance$3.element.is(':visible')) {
            MetaCluster._instance$3.slideUpEv();
        }
        else {
            MetaCluster._instance$3.slideDownEv();
        }
    }
    MetaCluster._instance$3.refresh();
}
MetaCluster._testAuthenticate$3 = function MetaCluster$_testAuthenticate$3() {
    /// <returns type="Boolean"></returns>
    if (ss.isValue(Nsb.Storage.getLocal('TestUserId'))) {
        FbDataStore.prototype.authenticateAw = MetaCluster.testAuthAw;
        ThemeBase.testing = true;
    }
    return !MetaCluster._usersSimulated$3;
}
MetaCluster._registerBar$3 = function MetaCluster$_registerBar$3() {
    /// <returns type="Boolean"></returns>
    $(document).unbind('.metabar').bind('MBToggle.metabar', MetaCluster.toggleEv);
    return !MetaCluster._regestered$3;
}
MetaCluster.testAuthAw = function MetaCluster$testAuthAw(awp) {
    /// <param name="awp" type="Await">
    /// </param>
    var id = (Nsb.Storage.getLocal('TestUserId') || MetaCluster.testUsers['Nathan']);
    new Await().addAw(ProfileData.getUserByIdAw, id).addDx(function(aw) {
        var ysr = aw.get_item('result');
        if (ysr != null) {
            Master.profile.set_my(ysr);
        }
    }).commit(awp);
}
MetaCluster.prototype = {
    _barMargin$3: null,
    _bodyMargin$3: null,
    _testBtn$3: null,
    _testSuite$3: null,
    _userBoxUpdate$3: false,
    
    refresh: function MetaCluster$refresh() {
        if (this._testBtn$3 != null) {
            new Await().loadScript(Uri.app('sc/Tests.js')).handleDl(Exceptions.blobLoadError, Await.finishAw).addDx(ss.Delegate.create(this, function() {
                Test.testUserId = 'TestUserId';
                TestSuite.teller = MetaCluster.testTeller;
                TestSuite.tell(null);
                this._testSuite$3 = TestSuite.getTestSuiteByPage(ThemeYoshi.currentPageName);
                var list = (this._testSuite$3 != null) ? this._testSuite$3.testList() : {};
                new TestListMenu(this._testBtn$3, list, ss.Delegate.create(this, function(e, item) {
                    this._testSuite$3.run(item);
                }));
                this._updateUserBox$3(Nsb.Storage.getLocal('TestUserId'));
            })).commit();
        }
    },
    
    _updateUserBox$3: function MetaCluster$_updateUserBox$3(id) {
        /// <param name="id" type="String">
        /// </param>
        if (Master.fbUser == null) {
            window.setTimeout(ss.Delegate.create(this, function() {
                this._updateUserBox$3(id);
            }), 13);
            return;
        }
        if (id != null) {
            new Await().addDx(ss.Delegate.create(this, function() {
                this._userBoxUpdate$3 = true;
            })).addDx(function() {
                MetaCluster.userSelect.val(id);
            }).addDx(ss.Delegate.create(this, function() {
                this._userBoxUpdate$3 = false;
            })).commit();
        }
    },
    
    slideDownEv: function MetaCluster$slideDownEv(e) {
        /// <param name="e" type="jQueryEvent">
        /// </param>
        Nsb.Storage.setLocal(ThemeYoshi.get_metaBarKey(), true);
        $(document.body).animate({ 'padding-top': this._barMargin$3 }, { duration: 100 });
        this.slideDownAw(Await.get_asyncAw(), 100);
    },
    
    slideUpEv: function MetaCluster$slideUpEv(e) {
        /// <param name="e" type="jQueryEvent">
        /// </param>
        Nsb.Storage.setLocal(ThemeYoshi.get_metaBarKey(), false);
        $(document.body).animate({ 'padding-top': this._bodyMargin$3 }, { duration: 100 });
        this.slideUpAw(Await.get_asyncAw(), 100);
    },
    
    destroy: function MetaCluster$destroy() {
        MetaCluster._instance$3 = null;
        this.slideUpEv();
        Nsb.Storage.removeLocal(ThemeYoshi.get_metaBarKey());
        this.element.remove();
    },
    
    changeUser: function MetaCluster$changeUser(id) {
        /// <param name="id" type="String">
        /// </param>
        if (this._userBoxUpdate$3) {
            return;
        }
        if (id === 'live') {
            Nsb.Storage.removeLocal('TestUserId');
            window.location.reload(true);
        }
        else {
            FbDataStore.prototype.authenticateAw = MetaCluster.testAuthAw;
            ThemeBase.testing = true;
            Nsb.Storage.setLocal('TestUserId', id);
            Master.GoPage(ThemeYoshi.currentPageName);
            this._updateUserBox$3(id);
        }
    }
}


CssInfo.registerClass('CssInfo', Actor);
Test.registerClass('Test', Await);
TestSuite.registerClass('TestSuite');
TestListMenu.registerClass('TestListMenu', DropMenu);
MetaCluster.registerClass('MetaCluster', Actor);
CssInfo._instance$3 = null;
CssInfo._cssProps$3 = [ 'position', 'top', 'bottom', 'left', 'right', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', 'z-index' ];
Test.defaultTestSpeed = 1;
Test.waitSleep = 13;
Test.hasContent = '[HasContent]';
Test.isEmpty = '[IsEmpty]';
Test.isNumber = '[IsNumber]';
Test.askOkBtn = '.Ask .OkBtn';
Test.askCancelBtn = '.Ask .CancelBtn';
Test.maxWait = 10000;
Test.testSpeed = 1;
Test._indent$1 = '';
Test._savedSpeeds$1 = [];
Test.testUserId = null;
Test.testVars = {};
Test._rxNumber$1 = new RegExp('^[-+]?\\d+(\\.\\d+)?$');
Test._instances$1 = {};
Test._recurStop$1 = 0;
TestSuite.allTestsName = '! Run page suite';
TestSuite.suites = {};
TestSuite.teller = null;
MetaCluster.testUserId = 'TestUserId';
MetaCluster._instance$3 = null;
MetaCluster._usersSimulated$3 = MetaCluster._testAuthenticate$3();
MetaCluster.testTeller = null;
MetaCluster.userSelect = null;
MetaCluster._regestered$3 = MetaCluster._registerBar$3();
MetaCluster.testUsers = { TestUser1: 'TestUser1', TestUser2: 'TestUser2', TestUser3: 'TestUser3', Nathan: '1305946510', Natalie: '793889201', Shallon: '746605760', Kickin: '100002776766039' };
})();

//! This script was generated using Script# v0.7.4.0
